package com.barneyx.mshinfoplatform.web.admin;

import com.barneyx.mshinfoplatform.common.ExResult;
import com.barneyx.mshinfoplatform.entity.info.InfoCateTagsEntity;
import com.barneyx.mshinfoplatform.util.InfoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/admin/info/cate/tag/")
@Slf4j
public class AdminInfoCateTagController {
    @Resource
    private InfoUtil.Cate.Tag tagUtil;

    @GetMapping("update-by-get")
    public ExResult<?> updateCateTagById(@RequestParam("tagid") String tagId,
                                         @RequestParam("tagname") String tagName,
                                         @RequestParam("tagcolor") String tagColor) {
        return ExResult.ofAuto(tagUtil.changeTagName(tagId, tagName, tagColor));
    }

    @GetMapping("tag-list-by-cate-id")
    public ExResult<?> listTagByCateId(@RequestParam("cateid") String cateId) {
        return ExResult.ofAuto(tagUtil.getList(cateId));
    }


    @DeleteMapping("delete-by-id")
    public ExResult<?> deleteTagById(@RequestParam("tagid") String tagId) {
        return ExResult.ofAuto(tagUtil.deleteTagById(tagId));
    }

    @PostMapping("create-tag")
    public ExResult<?> createTag(@RequestBody InfoCateTagsEntity tag) {
        return ExResult.ofAuto(tagUtil.createTag(tag));
    }
}